#!/bin/bash

if [[ -z $ID ]]; then
	echo "Error: database ID not given. Aborting."
	exit 1
fi

HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" 
cd $HERE/../..

CONF="/var/opt/redislabs/redis/redis-$ID.conf"
PORT=$(grep "^port" $CONF | awk '{print $2}')
PWD=$(grep "^requirepass" $CONF | awk '{print $2;}')

/var/opt/redislabs/bin/python /opt/view/RedisGears/recipes/gears.py --port $PORT --password $PWD ./write_behind.py

exit 0
